<?php
/**
 * @Author: chr
 * @Date:   2018-03-09 11:23:43
 * @Last Modified by:   chr
 * @Last Modified time: 2018-03-09 12:54:03
 */
include('common.php');

//上传PDF
if($_FILES["file"]["type"] == "application/pdf" && $_FILES["file"]["size"] < 5*1024*1024){ //判断文件类型和文件的大小
    if($_FILES["file"]["error"]){
        header('Refresh:3,Url=index.php');
        echo "上传文件出现错误<br />";
        echo "3s后跳转";
    }else{
        if(file_exists("upload/".$_FILES["file"]["name"])){ //判断文件是否存在
            header('Refresh:3,Url=index.php');
            echo "文件已经存在<br />";
            echo "3s后跳转";
        }else{
            $path = $_FILES['file']['name'];
            $pathinfo = pathinfo($path);
            $typename = $pathinfo['extension']; //文件的扩展名
            $filename = time().".".$typename;
            move_uploaded_file($_FILES["file"]["tmp_name"], "upload/".$filename); //上传文件
            echo "文件上传成功：" . "upload/" . $_FILES["file"]["name"];
            $file_path = "upload/".$filename; //文件路径
            header("Location:read_pdf.php?filename=$file_path");
        }
    }
}else{
    header("Refresh:3,Url=index.php");
    echo "上传文件不符合类型<br />";
    echo "3s后跳转";
}






?>